package com.yy.yyui.checkbox
{
	
	import com.yy.yyui.ISelectable;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;

	public class CheckLabel extends Sprite implements ISelectable
	{
		private var _actions:Object;
		private var _selected:Boolean;	
		private var selectedSkin:DisplayObject;
		private var unselectedSkin:DisplayObject;
		public function CheckLabel(selected:DisplayObject = null,unselected:DisplayObject= null)
		{
			//TODO: implement function
			
			super();
			//this.selectedSkin = selected==null?new Selected():selected;
			//this.unselectedSkin = unselected==null?new UnSelected():unselected;
			this.addChild(selectedSkin);
			this.addChild(unselectedSkin);
			selectedSkin.y +=2;
			unselectedSkin.y +=2;
			
			//set actions
			this._actions = {};
			this.addEventListener(MouseEvent.CLICK,clickHandler);
			//this.onSelect =  this.defaultOnSelect;
			
			
			this.selected = false;
		}
		
		private function clickHandler(e:Event):void{
			this.onSelect(e);
		}
		
		public function defaultOnSelect(e:Event):void{
			this.selected=!this.selected;
		}
		
		public function get actions():Object
		{
			//TODO: implement function
			return _actions;
		}
		
		public function get selected():Boolean
		{
			//TODO: implement function
			return this._selected;
		}
		
		public function set selected(value:Boolean):void
		{
			//TODO: implement function
			this._selected = value;
			this.selectedSkin.visible = this.selected;
			this.unselectedSkin.visible = !this.selected;
		}
		
		public function get onSelect():Function
		{
			//TODO: implement function
			return this.actions.onSelect;
		}
		
		public function set onSelect(value:Function):void
		{
			//TODO: implement function
			this.actions.onSelect = value;
		}
		
	}
}